/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.sys.entity;

import javax.validation.Valid;

import org.hibernate.validator.constraints.Length;

import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import com.jeesite.common.utils.excel.fieldtype.CompanyType;
import com.jeesite.common.utils.excel.fieldtype.EduIndustryType;
import com.jeesite.common.utils.excel.fieldtype.EduTalentType;
import com.jeesite.common.utils.excel.fieldtype.EduTwoOrganizationType;
import com.jeesite.common.utils.excel.fieldtype.LevelType;
import com.jeesite.common.utils.excel.fieldtype.NatureType;
import com.jeesite.common.utils.excel.fieldtype.OfficeType;
import com.jeesite.common.utils.excel.fieldtype.PostListType2;
import com.jeesite.common.utils.excel.fieldtype.ProfessionalType;
import com.jeesite.common.utils.excel.fieldtype.SubjectType;
import com.jeesite.common.utils.excel.fieldtype.TeacherType;

/**
 * 员工用户管理Entity
 * @author ThinkGem
 * @version 2017-03-25
 */
@Table(name="${_prefix}sys_user", alias="a", columns={
		@Column(includeEntity=User.class),
	}, joinTable={
		@JoinTable(type=Type.JOIN, entity=Employee.class, alias="e",
			on="e.emp_code=a.ref_code AND a.user_type=#{USER_TYPE_EMPLOYEE}",
			attrName="employee", columns={
					@Column(includeEntity=Employee.class)
			}),
		@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, alias="o", 
			on="o.office_code=e.office_code", attrName="employee.office",
			columns={
					@Column(name="office_code", label="机构编码", isPK=true),
					@Column(name="parent_codes",label="所有父级编码", queryType=QueryType.LIKE),
					@Column(name="view_code", 	label="机构代码"),
					@Column(name="office_name", label="机构名称", isQuery=false),
					@Column(name="full_name", 	label="机构全称"),
					@Column(name="office_type", label="机构类型"),
					@Column(name="leader", 		label="负责人"),
					@Column(name="phone", 		label="电话"),
					@Column(name="address", 	label="联系地址"),
					@Column(name="zip_code", 	label="邮政编码"),
					@Column(name="email", 		label="邮箱"),
					@Column(name="extend_s3", 		label="办学层次"),
					@Column(name="extend_s4", 		label="办学性质"),
			}),
		@JoinTable(type=Type.LEFT_JOIN, entity=Company.class, alias="c", 
			on="c.company_code=e.company_code", attrName="employee.company",
			columns={
					@Column(name="company_code", label="公司编码", isPK=true),
					@Column(name="parent_codes",label="所有父级编码", queryType=QueryType.LIKE),
					@Column(name="view_code", 	label="公司代码"),
					@Column(name="company_name", label="公司名称", isQuery=false),
					@Column(name="full_name", 	label="公司全称"),
					@Column(name="area_code", attrName="area.areaCode", label="区域编码"),
			}),
		@JoinTable(type=Type.LEFT_JOIN, entity=Area.class, alias="ar",
			on="ar.area_code = c.area_code", attrName="employee.company.area",
			columns={
					@Column(name="area_code", label="区域代码", isPK=true),
					@Column(name="area_name", label="区域名称", isQuery=false),
					@Column(name="area_type", label="区域类型"),
		}),
	},
	extWhereKeys="dsfOffice, dsfCompany, dsfEmployee",
	orderBy=" a.update_date DESC"
)
public class EmpUser extends User {
	
	private static final long serialVersionUID = 1L;

	public EmpUser() {
		this(null);
	}

	public EmpUser(String id){
		super(id);
	}
	
	


	@Valid
	@ExcelFields({
		@ExcelField(title="姓名", attrName="userName", align=Align.CENTER, sort=2),
		@ExcelField(title="身份证号", attrName="loginCode", align=Align.CENTER, sort=3),
		@ExcelField(title="性别", attrName="sex", align=Align.CENTER,dictType="sys_user_sex", sort=4),
		@ExcelField(title="手机号", attrName="mobile", align=Align.CENTER, sort=5),
		@ExcelField(title="国籍", attrName="extend.extendS1",type = ExcelField.Type.EXPORT,dictType="js_sys_country", align=Align.CENTER, sort=6),
		@ExcelField(title="民族", attrName="extend.extendS2",type = ExcelField.Type.EXPORT,dictType="nation",		align=Align.CENTER, sort=7),
		@ExcelField(title="政治面貌", attrName="extend.extendS3",type = ExcelField.Type.EXPORT,dictType="political",	align=Align.CENTER, sort=8),
		@ExcelField(title="所聘岗位", attrName="userCode",type = ExcelField.Type.EXPORT,fieldType=PostListType2.class, align=Align.CENTER, sort=9),
		@ExcelField(title="供职院校", attrName="employee.office", fieldType=OfficeType.class, align=Align.CENTER, sort=10),
		@ExcelField(title="机构名称", attrName="employee.eduTwoOrganization",  fieldType=EduTwoOrganizationType.class, align=Align.CENTER, sort=11),
		@ExcelField(title="所在内设机构职务", attrName="employee.organization", align=Align.CENTER, sort=12),
		@ExcelField(title="办学层次", attrName="employee.office", fieldType=LevelType.class, type = ExcelField.Type.EXPORT,align=Align.CENTER, sort=13),
		@ExcelField(title="办学性质", attrName="employee.office", fieldType=NatureType.class, type = ExcelField.Type.EXPORT,align=Align.CENTER, sort=14),
		@ExcelField(title="最高学历毕业院校", attrName="employee.company", fieldType=CompanyType.class, align=Align.CENTER, sort=15),
		@ExcelField(title="学校所在区域", attrName="employee.company.area.areaName",type = ExcelField.Type.EXPORT, align=Align.CENTER, sort=16),
		@ExcelField(title="最高学历", attrName="employee.highestEdu",dictType="highest_edu", align=Align.CENTER, sort=17),
		@ExcelField(title="最高学位", attrName="employee.highestDegree",dictType="highest_degree", align=Align.CENTER, sort=18),
		
		@ExcelField(title="博士后", attrName="employee.isPostdoctor",type = ExcelField.Type.EXPORT,dictType="sys_yes_no", align=Align.CENTER, sort=19),
		
		@ExcelField(title="最高学历所学专业", attrName="employee.subjectMajor",fieldType=SubjectType.class, align=Align.CENTER, sort=20),
		@ExcelField(title="博士后国（境）外学习情况", attrName="employee.learningSituation",dictType="school_abroad", align=Align.CENTER, sort=21),
		@ExcelField(title="专业技术职务1", attrName="employee.eduTeacherTitle",type = ExcelField.Type.EXPORT,fieldType=TeacherType.class, align=Align.CENTER, sort=22),
		@ExcelField(title="专业技术职务2", attrName="employee.eduProfessionalTitle",type = ExcelField.Type.EXPORT,fieldType=ProfessionalType.class, align=Align.CENTER, sort=23),
		@ExcelField(title="专业技术职务级别", attrName="employee.eduProfessionalTitle",type = ExcelField.Type.EXPORT,fieldType=ProfessionalType.class, align=Align.CENTER, sort=24),

		@ExcelField(title="(入选年份)人才称号", attrName="userCode",fieldType=EduTalentType.class,type = ExcelField.Type.EXPORT, align=Align.CENTER, sort=25),
		@ExcelField(title="所教授的学生层次", attrName="employee.studentLevel",dictType="sys_student_level", align=Align.CENTER, sort=26),
		
		@ExcelField(title="学科门类", attrName="employee.subject",fieldType=SubjectType.class, align=Align.CENTER, sort=27),
		
		@ExcelField(title="担任导师", attrName="employee.mentor",dictType="sys_mentor",  align=Align.CENTER, sort=28),
		
		@ExcelField(title="本人专业研究方向学科门类", attrName="employee.subjectResearch",fieldType=SubjectType.class,type = ExcelField.Type.EXPORT, align=Align.CENTER, sort=29),
		@ExcelField(title="专业研究主要面向哪类行业（研究领域对口的行业）", attrName="employee.eduIndustry",fieldType=EduIndustryType.class,type = ExcelField.Type.EXPORT, align=Align.CENTER, sort=30),
		
		@ExcelField(title="学校兼职", attrName="employee.schoolJob",dictType="school_job", align=Align.CENTER, sort=31),
		@ExcelField(title="企业兼职", attrName="employee.industryJob",dictType="industry_job", align=Align.CENTER, sort=32),
		@ExcelField(title="国（境）外工作情况", attrName="employee.workJob",dictType="work_abroad", align=Align.CENTER, sort=33),
		@ExcelField(title="详情描述", attrName="employee.detail", align=Align.CENTER, sort=34),
	})
	public Employee getEmployee(){
		Employee employee = (Employee)super.getRefObj();
		if (employee == null){
			employee = new Employee();
			super.setRefObj(employee);
		}
		return employee;
	}
	
	public void setEmployee(Employee employee){
		super.setRefObj(employee);
	}

	@Override
	public String toString() {
		return "EmpUser [getEmployee()=" + getEmployee() + "]";
	}
	
}